package com.ruicar.afs.cloud.apply.business.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.apply.common.entity.TSysParamConfig;
import com.ruicar.afs.cloud.apply.business.mapper.TSysParamConfigMapper;
import com.ruicar.afs.cloud.apply.business.service.TSysParamConfigService;
import org.springframework.stereotype.Service;

/**
 * 参数配置service实现类
 *
 * @author 耿继辉
 */
@Service
public class TSysParamConfigServiceImpl extends ServiceImpl<TSysParamConfigMapper, TSysParamConfig> implements TSysParamConfigService {

    /**
     * 通过场景参数和具体参数获取参数值
     * @param paramNo
     * @param magicNo
     * @param defaultValue
     * @return
     */
    public String getParamValue(String paramNo,String magicNo,String defaultValue){

        TSysParamConfig paramConfig = this.baseMapper.selectOne(Wrappers.<TSysParamConfig>query().lambda().eq(TSysParamConfig::getParamNo,paramNo).eq(TSysParamConfig::getMagicNo,magicNo));
        if(paramConfig != null){
            return paramConfig.getParamValue();
        }
        return defaultValue;
    }
}
